***
* Exploring mechanisms of Dodd-Frank
***

* set working directory
cd "C:\Users\jeffrey.bloem\OneDrive - USDA\Dodd Frank\Dodd Frank\Replication files"

* import IPIS data
clear
import delimited "cod_mines_curated_all_opendata_p_ipis.csv", encoding(ISO-8859-1)

* basic diff-in-diff model

gen df = 0 if visit_year<2011
replace df = 1 if visit_year>2010

gen did = df*is_3t_mine

encode territoire, gen(terr_id)
encode province, gen(prov_id)
tostring visit_year, gen(year)
encode year, gen(year_id)

gen x = workers_num
gen ihs_workers = ln(x + ((x)^2 + 1)^0.5)

reg ihs_workers is_3t_mine df did, cluster(terr_id)
outreg2 is_3t_mine df did using Table1.tex, replace
reg ihs_workers is_3t_mine df did i.year_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table1.tex
reg ihs_workers is_3t_mine df did i.year_id i.terr_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table1.tex
reg presence is_3t_mine df did, cluster(terr_id)
outreg2 is_3t_mine df did using Table1.tex
reg presence is_3t_mine df did i.year_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table1.tex
reg presence is_3t_mine df did i.year_id i.terr_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table1.tex

sum presence if is_3t_mine == 1 & df == 0

drop if visit_year>2015

reg ihs_workers is_3t_mine df did, cluster(terr_id)
outreg2 is_3t_mine df did using Table2.tex, replace
reg ihs_workers is_3t_mine df did i.year_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table2.tex
reg ihs_workers is_3t_mine df did i.year_id i.terr_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table2.tex
reg presence is_3t_mine df did, cluster(terr_id)
outreg2 is_3t_mine df did using Table2.tex
reg presence is_3t_mine df did i.year_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table2.tex
reg presence is_3t_mine df did i.year_id i.terr_id, cluster(terr_id)
outreg2 is_3t_mine df did using Table2.tex

sum presence if is_3t_mine == 1 & df == 0

